﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ExamSharedClasses.Commands;
using ExamSharedClasses;

namespace ExamClient
{
    /// <summary>
    /// (k) Der Frame, um eine Multiple-Choicefrage mit nur einer richtigen Antwort darzustellen
    /// </summary>
    public partial class QuestionTypeSingleMultiplePage : Page {

        public AnswerTypeSingleMultiple AnswerTypeSingleMultiple { get; set; }
        public int Index { get; set; }

        public QuestionTypeSingleMultiplePage( AnswerTypeSingleMultiple answerTypeSingleMultiple) {
            InitializeComponent();
            this.AnswerTypeSingleMultiple = answerTypeSingleMultiple;
            UpdateWindow();
            radioButton1.Focus();
        }

        public void UpdateWindow() {
            QuestionTypeSingleMultiple qtsm = ( QuestionTypeSingleMultiple )AnswerTypeSingleMultiple.AnswerQuestion;
            questionTextBlock.Text = qtsm.QuestionBody;
            radioButton1.Content = qtsm.QuestionAnswer1;
            radioButton2.Content = qtsm.QuestionAnswer2;
            if ( ( qtsm.QuestionAnswer3 != null && !( qtsm.QuestionAnswer3.Equals( "" ) ) ) )
                radioButton3.Content = qtsm.QuestionAnswer3;
            else
                radioButton3.IsEnabled = false;
            if ( qtsm.QuestionAnswer4 != null && !( qtsm.QuestionAnswer4.Equals( "" ) ) )
                radioButton4.Content = qtsm.QuestionAnswer4;
            else
                radioButton4.IsEnabled = false;
        }


        private void answerButton_Click( object sender, RoutedEventArgs e ) {
            int summe = 0;
            summe += radioButton1.IsChecked == true ? 1 : 0;
            summe += radioButton2.IsChecked == true ? 2 : 0;
            summe += radioButton3.IsChecked == true ? 4 : 0;
            summe += radioButton4.IsChecked == true ? 8 : 0;
            AnswerTypeSingleMultiple.AnswerUserAnswer = summe;
            AnswerTypeSingleMultiple.AnswerUserId = App.UserAddress.UserId;
            passButton_Click( null, null );
        }
        private void passButton_Click( object sender, RoutedEventArgs e ) {
            App.ExamPage.BindNextPageToFrame();
        }
    }


}
